package com.tang.designpattern.singleton;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/4/30 17:59
 * DCL（双重检查锁）懒汉式
 */
public class SingletonDemo03 {
    //私有化构造器
    private SingletonDemo03(){

    }
    private static volatile SingletonDemo03 instance;
    //提供获取该对象的方法
    public static SingletonDemo03 getInstance(){
        if(instance==null){
            synchronized (SingletonDemo03.class){
                if(instance==null){
                    instance = new SingletonDemo03();
                }
            }
        }
        return instance;
    }
}
